The Default CDEF is a simple aid for Macintosh programmers that draws default button outlines. Default correctly handles buttons of any size and color. Since it works in both your application and your ResEdit dialog and alert templates, Default is useful both for development and for finished products. Default can also draw push buttons, check boxes, and radio buttons using the window’s font. Sample code is also provided for a user item procedure that draws default outlines.
___Instructions___
Default is a control definition function that you can copy and paste into your application. The Default CDEF enhances the System file’s standard control definition 0. If the last character of a button’s title is an ‘@’ (an “at” or an “each” symbol), the button is drawn with an outline indicating that it is the default button. The trailing ‘@’ is not drawn with the title.
When Color QuickDraw is available, outlines are drawn in the same color as the button’s frame. If the button is inactive, the outline is grayed out. If System 7 or later is being used, the outline is grayed out using the same method as the grayishTextOr mode. If the Default CDEF is in the same file as your application’s DITL resources, ResEdit will display default button outlines drawn by Default. You do not need to write any code to use Default.
A dialog’s default button can be changed at any time in your application simply by changing the appropriate button titles. However, you, the programmer, are responsible for making sure there is only one default button. If you are not using a filterProc, Default makes sure that pressing the Return key or Enter key is the same as clicking in the default button. The Dialog Manager will also highlight the default button when the Return key or Enter key is pressed. If you are using your own filterProc, you must perform these tasks.
If the last character of a control’s title is an ‘ƒ’, the control is drawn using the window’s current font. Push buttons, check boxes, and radio buttons will look the same as if you used a CNTL resource with the useWFont variation code. This feature is especially useful for Control Panel device dialogs. If you need a default button that uses the window’s font, end the button’s title with ‘ƒ@’.
DefaultItem is a user item procedure that draws the same outlines as Default. If you prefer to draw outlines with user items or if you are writing a desk accessory, DefaultItem is for you. The Default CDEF is not compatible with the resource numbering scheme used by desk accessories.
___Compatibility___
Default should work on any model of Macintosh with any System version. Default is 32-bit clean. Except for drawing the outline, Default lets the System file’s CDEF 0 do practically everything. Thus, Default’s buttons do anything that normal buttons do.
Be warned that Default uses the contrlData field of a ControlRecord (which is okay since it is reserved for CDEFs). If your application does something strange with this field, Default will not work.
When you drag or resize a default button in ResEdit, Default might not be able to redraw the default button correctly. This happens because ResEdit doesn’t know about the outline. You can work around this by forcing ResEdit to update the window. With previous versions of Default, you could make Default automatically force ResEdit to update the window. This automatic updating code was removed because ResEdit 2.1 and later update the outline correctly.
___Bugs___
The outline will not update if the outline needs updating and the button does not, and UpdtControl or UpdtDialog is being used to update the controls. This problem does not occur with normal modal dialogs and rarely occurs with modeless dialogs. Unfortunately, there isn’t a clean solution for this problem. If you have this problem, you can call Draw1Control for the default button on every update event or simply use DrawControls or DrawDialog instead.
If you have a default button and you aren’t using a filterProc, pressing the Return key or Enter key will click in the default button even if the button is hidden. This is a bug in the Dialog Manager. If you have this problem, you must change the default button to a normal button before you call HideDItem or HideControl.
If you have a dialog with an edit text item and you want to use a different font style, transfer mode, or font size with the dialog, you must adjust the lineHeight, fontAscent, txFont, txFace, txMode, and txSize fields of the dialog’s textH TextEdit handle as needed. This is another bug in the Dialog Manager. If you just want a different font, SetDAFont works correctly.
Please report any other bugs to any of the addresses listed below. Thanks to those programmers who did unusual things with their buttons and reported bugs — they helped make Default more robust.
___History___
1.0 — first release
1.1 — fixed bug with HideControl and default buttons
1.2 — updated to support new 32-bit clean CDEF messages
1.3 — fixed bug with DragControl
1.4 — fixed bug converting between default buttons and normal buttons;
improved outlines for unusually sized default buttons
1.5 — forced ResEdit to refresh default buttons correctly
2.0 — added automatic Return and Enter support for default buttons;
added window font feature for push buttons, check boxes, and radio buttons;
restructured code to reduce size of CDEF
2.1 — updated to follow Apple’s new way of drawing default outlines
2.2 — fixed rare bug with Standard File Package;
removed ResEdit updating code;
added more optimizations to reduce code size;
added sample code for default user item procedure
2.3 — updated to support System 7 grayishTextOr disabling
___Distribution___
Default is available free of charge. You may copy and redistribute Default provided that this documentation accompanies any redistributed copies of Default and that the Default CDEF is not modified in any way. Default is owned and copyrighted by Lim Unlimited.
You may include Default in any commercial or non-commercial software that you distribute provided that the Default CDEF is not modified in any way and that Lim Unlimited is given a free, fully functional, and fully supported copy of your software.
The source code to Default is available on request. You can get a copy via electronic mail or by sending a disk and a stamped self-addressed envelope via postal mail. The source code may not be redistributed without the permission of Lim Unlimited. You may not distribute modified versions of the source code or any software derived from the source code.
Lloyd Lim
Lim Unlimited
Postal: 330 W. Iris Avenue, Stockton, CA 95210-3738, U.S.A.